/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode* getKthFromEnd(ListNode* head, int k) {
        ListNode* ans = head, *mov = head;
        for(int i = 0; i < k; i++){
            if(!mov)return nullptr;
            mov = mov->next;
        }
        while(mov){
            mov = mov->next;
            ans = ans->next;
        }
        return ans;
    }
};

//2021.4.19
//2021.9.2 每日一题 
